package com.webapp.domain.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;




@Entity
public class User extends BaseEntity{


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private long id;//id 主键
	
	private UserDetail userDetail;
	private String password;//密码/验证码
	private String email; //邮箱   /暂时没用上
	private Date createDate;//创建时间
	private String token;//用来记录登录信息随机码的用于在线仲裁
	private String isLogin;//1标记用户在线，0标记离线，2标记发送离线短信通知
	private String headPortrait;//用户头像
	private Integral integral;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return this.id;
	}
	public void setId(long id) {
		this.id = id;
	}
	@OneToOne(mappedBy="user",cascade=CascadeType.ALL,fetch=FetchType.LAZY,targetEntity=UserDetail.class)
	public UserDetail getUserDetail() {
		return userDetail;
	}
	public void setUserDetail(UserDetail userDetail) {
		this.userDetail = userDetail;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public String getIsLogin() {
		return isLogin;
	}
	public void setIsLogin(String isLogin) {
		this.isLogin = isLogin;
	}
	public String getHeadPortrait() {
		return headPortrait;
	}
	public void setHeadPortrait(String headPortrait) {
		this.headPortrait = headPortrait==null?"hp.png":headPortrait;
	}
	
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY,targetEntity=Integral.class)
	@JoinColumn(name="integral_id")
	public Integral getIntegral() {
		return integral;
	}
	public void setIntegral(Integral integral) {
		this.integral = integral;
	}
	
	
	
}
